import { getuserInfo, login } from "@/api/User";
export default {
    namespaced: true,
    state: {
        userInfo: {}
    },
    getters: {},
    mutations: {
        addScore(state, num = 1) {
            state.userInfo2.M_Score += num;
        },
        Set_User(state, user) {
            state.userInfo = user
        },
    },
    actions: {
        getUser(context) {
            getuserInfo().then(res => {
                console.log(res.data);
                if (res.data) {
                    sessionStorage.setItem("islog", true);
                    context.commit("Set_User", res.data)
                }
            })
        },
        lgout(context) {
            login({ "dopost": "exit" }, { loading: { message: "正在退出" } }).then(res => {
                if (res.data.status) {
                    sessionStorage.removeItem("islog")
                    context.commit("Set_User", {});
                }
            })
        }
    },

}